// @ts-check
var x = MOUSE
var geometry = new THREE.CubeGeometry(200, 100, 50, 4, 4);
var u = new BuildOptions()
document.addEventListener('DOMContentLoaded', function (e) {
  var isMouseDown = false;
  var clientX = 0
  var clientY = 0
  document.addEventListener('mousewheel', function (e) {
    if (e.wheelDelta) { //第一步：先判断浏览器IE，谷歌滑轮事件
      if (e.wheelDelta > 50) { //当滑轮向上滚动时
        camera.position.y -= 100;
      }
      if (e.wheelDelta < 50) {
        camera.position.y += 100;
      }
    }
  })

  document.addEventListener('mousedown', function (e) {
    isMouseDown = true;
    clientX = e.clientX;
    clientY = e.clientY;
  })

  document.addEventListener('mouseup', function (e) {
    isMouseDown = false;
  })

  document.addEventListener('mousemove', function (e) {
    var step = Math.PI / 180 * 0.08;
    if (isMouseDown) {
      // if (clientX < e.clientX) {
      //   camera.rotation.y -= step;
      // } else if (clientX > e.clientX) {
      //   camera.rotation.y += step;
      // }

      if (clientY < e.clientY) {
        camera.rotation.x -= step;
      } else if (clientY > e.clientY) {
        camera.rotation.x += step;
      }

      clientX = e.clientX;
      clientY = e.clientY;
    }
  })

  setInterval(function () {
    document.getElementById('fps').innerHTML = 'fps: ' + fps;
    fps = 0;
  }, 1000)
})